using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FPSContorller : MonoBehaviour
{
    public static FPSContorller Instance;//单例
    public float lookeSensitivity = 1f;

    private void Awake()
    {
        Instance = this;
    }

    private void Start()
    {
        //隐藏鼠标不可见
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    public Vector3 GetMoveInput()
    {
        Vector3 move = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
        move = Vector3.ClampMagnitude(move, maxLength: 1);
        return move;
    }

    public float GetMouseLookHorizontal()
    {
        return GetMouseLookAxis("Mouse X");
    }

    public float GetMouseLookVertical()
    {
        return GetMouseLookAxis("Mouse Y");
    }
    public float GetMouseLookAxis(string moseInputName)
    {
        float i = Input.GetAxisRaw(moseInputName);
        i *= lookeSensitivity * 0.01f;

        return i;
    }
    
    /*
     * 开枪
     */
    public bool GetFireInputHeld()
    {
        return Input.GetButton("Fire");
    }
}
